from curl_cffi import requests
import re

from util import proxies

for i in range(25):
    res = requests.get(f"https://tieba.baidu.com/f?kw=%E7%90%86%E6%83%B3%E6%B1%BD%E8%BD%A6&ie=utf-8&pn={i * 50}",
                       impersonate=requests.BrowserType.chrome120,
                       cookies={
                           'BAIDUID_BFESS': '4F0A0AC8D27F70E85411A627A65659CF:FG=1'
                       })
    contents = re.findall(r'<a rel="noopener" href="(.*?)" title=".*?" target="_blank" class="j_th_tit ">(.*?)</a>',
                          res.text)
    for item in contents:
        url = f'https://tieba.baidu.com{item[0]}'
        print(url, item[1])
        # res = requests.get(url, impersonate=requests.BrowserType.chrome120,
        #                    cookies={
        #                        'BAIDUID_BFESS': '4F0A0AC8D27F70E85411A627A65659CF:FG=1'
        #                    })
        # print(res)
